<!DOCTYPE html>
<html>
<head>
    <title>修改资料</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <link href="<%= global.config.path.publicPath %>/custom/officialAccount/css/officalCommon.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll_002.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll_003.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %><%= body.stylePath %>" rel="stylesheet">
    <link href="<%=global.config.cdn.path %>/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="<%=global.config.cdn.path %>/weui/0.4.3/style/weui.min.css">
    <link href="<%= global.config.path.publicPath %>/libs/area/css/area.css" rel="stylesheet">

    <link rel="stylesheet" href="<%=global.config.cdn.path %>/jquery-weui/0.8.3/css/jquery-weui.min.css">
    <style>
        .content-padded {
            padding: 15px;
        }
        body{
            background-color: #FBF9FE;
        }
        .fa-mobile-phone:before, .fa-mobile:before {
            content: "\f10b";
        }.fa-mobile-phone:before, .fa-mobile:before {
             content: "\f10b";
         }
        .fa-lg {
            font-size: 1.33333333em;
            line-height: .75em;
            vertical-align: -15%;
        }

        button.weui-vcode-btn {
            background-color: transparent;
            border-bottom: 0 none;
            border-right: 0 none;
            border-top: 0 none;
            outline: 0 none;
        }

        .weui-vcode-btn {
            border-left: 1px solid #e5e5e5;
            color: #3cc51f;
            display: inline-block;
            font-size: 17px;
            padding: 0 0.6em 0 0.7em;
        }

        .weui-vcode-btn, .weui-vcode-img {
            margin-left: 5px;
            vertical-align: middle;
        }

        .weui_cells {
            margin-top: 10px;
        }
    </style>

</head>
<body ontouchstart>
<div id="register" class="content-padded">
    <form id="modifyForm" method="post" class="clearfix" action="<%=global.config.path.contextPath%>/work/modify">
        <!--<input type="hidden" name="brand" value="mogu"/>-->
        <input hidden name="vipCode" value="<%=userData.cardCode%>">
        <input hidden name="openId" value="<%=userData.openid%>">
        <input hidden name="brand" >
        <input hidden name="publicId">
        <input hidden name="gId">
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" id="vipMobile" type="text" placeholder="请输入您的手机号码" name="vipMobile" value="<%=userData.mobile%>">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input acc-input" type="text" placeholder="请输入您的真实姓名" name="vipName" value="<%=userData.vipName%>">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="text" disabled="" value="<%=userData.birthday%>">
                    <input type="hidden" name="vipBirthday" value="<%=userData.birthday%>">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="text" id="vipSex" placeholder="性别" name="vipSex" value="<%=userData.genderName%>" readonly="">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form" hidden>
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="text" id="address-input" placeholder="您的地址" name="vipAddress" value="<%=userData.address%>" readonly="">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">

            <div class="browser" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <!--选择地区-->
                <section class="express-area">
                    <a id="expressArea" href="javascript:void(0)">
                        <dl>
                            <dt>选择地区：</dt>
                            <dd>省 > 市 > 区/县</dd>
                        </dl>
                    </a>
                </section>
                <!--选择地区弹层-->
                <section id="areaLayer" class="express-area-box">
                    <header>
                        <h3>选择地区</h3>
                        <a id="backUp" class="back" href="javascript:void(0)" title="返回"  style="background-image: url('<%=global.config.path.publicPath%>/images/back.png')"></a>
                        <a id="closeArea" class="close" href="javascript:void(0)" title="关闭"  style="background-image: url('<%=global.config.path.publicPath%>/images/close-area.png')"></a>
                    </header>
                    <article id="areaBox">
                        <ul id="areaList" class="area-list"></ul>
                    </article>
                </section>
                <!--遮罩层-->
                <div id="areaMask" class="mask"></div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <input type="submit" class="weui_btn weui_btn_default" value="提交修改" onclick="return check(this.form)">
        </div>
    </form>
</div>

<% include common/footer.ejs %>
<script src="<%=global.config.cdn.path %>/jquery/1.11.0/jquery.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/jquery-weui.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/swiper.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/city-picker.min.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/area/js/jquery.area.js"></script>


<script>

    function check(form) {
        if (form['vipName'].value == '') {
            alert("请输入您的姓名!");
            form['vipName'].focus();
            return false;
        }
        if(!(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(form.vipMobile.value) || (/^(5|6|8|9)\d{7}$/).test(form.vipMobile.value))){
            alert("请输入正确的手机号码！");
            form.vipMobile.focus();
            return false;

        }
        if (form.vipBirthday.value == '') {
            alert("请输入您的生日!");
            form.vipBirthday.focus();
            return false;
        }
        return true;
    }

    $(function () {
        $("#expressArea dl dd").html('<%=userData.address%>');
        console.log($('#areaLayer').val());

        function urlParse(url) {
            var result = {}
            var elems = url.split('?')[1].split('&')

            elems.forEach(function(e){
                var keyVal = e.split('='),
                    key = keyVal[0]
                val = keyVal[1] || ''       //没有value的情况下表示为‘’而非undefined

                if(result[key] !== void 0){     //属性有两个以上的值，存储为字符串数组
                    console.log(result[key]);
                    result[key] = [].concat(result[key]).concat(val)
                }else{                          //只有一个属性值，以字符串形式存储
                    result[key] = val
                }
            })

            return result
        };
        let form = document.querySelector('#modifyForm');
        let param = urlParse(window.location.href);
        console.log(param.publicId);
        form.gId.value = param.gId;
        form.publicId.value = param.publicId;
        form.brand.value = param.brand;

        $("#vipSex").select({
            title: "选择性别",
            items: [
                {
                    title: "男",
                    value: "男"
                },
                {
                    title: "女",
                    value: "女"
                }
            ]
        });

    });

</script>
</body>
</html>
